OpenBuildings GenerativeComponents Help

To create a Script Function

  1. Select (Show Functions ) to access the functions.

    The Functions dialog opens listing the standard library functions as well as script functions.

  2. Click (New Script Function) tool in the taskbar. Opens the Script Editor where you can write the script for your function.
  3. The Script Editor opens with default function name assigned in the header line void Function1(). The tab of Script Editor shows the [New Function].
  4. Name the function with proper syntax (other than reserved, key words) and assign the type.

    In our example, replace the type void by double and Function01() by ScriptFunction01.

  5. Write valid script expressions in the script body and select Tools > Load to register the function.
    A valid script will save the named function in the Functions dialog.
    Note: Check the Filter > Include Script Functions to narrow down the list and view only script functions.
  6. In the Functions dialog list, select the newly created script function, ScriptFunction01 and click on the Apply To.. > <new FunctionCall node> . The functionCall node appears in the graph view.
    The auto increment number prefix "1" is added to a new functionCall node. Existing functionCalls, if available will list under the Apply To.. option

    Note that the function call functionCall01 drives the script function ScriptFunction01 applied in it.

    You can always use the tool icon on the functionCall node to access the Function dialog to amend the function script, and/or assign different function to the function call node.

  7. Connect the nodal port to desired input port to supply the return value of the script function.

    In our example, we connect the wire from functionCall01 node to XTransition of point01.

  8. (Optional) Supply value at input port by clicking the inputVal_1 and run the transaction. The script function doubles the value feed in the inputVal_1 input, and as a result the point1 displaces to that value in the X direction.